/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * AdminCompte.java
 *
 * Created on 18 janv. 2011, 17:42:04
 */
/**
 * suite le 19 janvier
 */
package org.cinema.view.admin;

import java.io.IOException;
import java.sql.SQLException;
import java.text.DateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.GregorianCalendar;
import java.util.Locale;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JOptionPane;
import org.cinema.dao.film.FilmsDao;
import org.cinema.dao.film.FilmsInfo;

/**
 *
 * @author lynda and wydad
 */
public class AdminCompte extends javax.swing.JFrame {
    // declaration

    FilmsDao filmDao;
    ArrayList<FilmsInfo> filmsList;
    FilmsInfo film;
    int recordNumber;
 

    /** Creates new form AdminCompte */
    public AdminCompte() throws InstantiationException, IllegalAccessException {
        initComponents();
        filmDao = new FilmsDao();
        Date d = new Date();
        DateFormat df = DateFormat.getDateInstance( DateFormat.FULL ,
                Locale.FRANCE );
       jLabel2.setText("Bonjour Admin");
       jLabel4.setText(df.format(d));
                
       
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jMenuBar2 = new javax.swing.JMenuBar();
        jMenu6 = new javax.swing.JMenu();
        jMenu7 = new javax.swing.JMenu();
        jMenuBar3 = new javax.swing.JMenuBar();
        jMenu9 = new javax.swing.JMenu();
        jMenu11 = new javax.swing.JMenu();
        jPanel1 = new javax.swing.JPanel();
        jLabel1 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        jLabel4 = new javax.swing.JLabel();
        jMenuBar1 = new javax.swing.JMenuBar();
        jMenu1 = new javax.swing.JMenu();
        jMenuItem1 = new javax.swing.JMenuItem();
        jMenu2 = new javax.swing.JMenu();
        jMenuItem4 = new javax.swing.JMenuItem();
        jMenuItem6 = new javax.swing.JMenuItem();
        jMenu4 = new javax.swing.JMenu();
        jMenuItem8 = new javax.swing.JMenuItem();
        jMenu3 = new javax.swing.JMenu();
        jMenuItem5 = new javax.swing.JMenuItem();
        jMenu10 = new javax.swing.JMenu();
        jMenuItem7 = new javax.swing.JMenuItem();
        jMenu5 = new javax.swing.JMenu();
        jMenuItem2 = new javax.swing.JMenuItem();
        jMenuItem3 = new javax.swing.JMenuItem();
        jMenu8 = new javax.swing.JMenu();
        jMenuItem9 = new javax.swing.JMenuItem();

        jMenu6.setText("File");
        jMenuBar2.add(jMenu6);

        jMenu7.setText("Edit");
        jMenuBar2.add(jMenu7);

        jMenu9.setText("File");
        jMenuBar3.add(jMenu9);

        jMenu11.setText("Edit");
        jMenuBar3.add(jMenu11);

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setTitle("Gestion Cinema\n");
        setBounds(new java.awt.Rectangle(250, 60, 0, 0));
        setResizable(false);
        addContainerListener(new java.awt.event.ContainerAdapter() {
            public void componentAdded(java.awt.event.ContainerEvent evt) {
                formComponentAdded(evt);
            }
        });

        jPanel1.setBackground(new java.awt.Color(255, 255, 255));
        jPanel1.setMaximumSize(new java.awt.Dimension(1000, 1000));

        jLabel1.setIcon(new javax.swing.ImageIcon("C:\\Users\\lynda\\Documents\\NetBeansProjects\\GestionCinema\\tools\\images\\gestion cinema.jpg")); // NOI18N

        jLabel2.setFont(new java.awt.Font("Times New Roman", 1, 14));
        jLabel2.setForeground(new java.awt.Color(51, 153, 255));

        jLabel3.setIcon(new javax.swing.ImageIcon("C:\\Users\\lynda\\Documents\\movie.jpg")); // NOI18N

        jLabel4.setFont(new java.awt.Font("Tahoma", 1, 12));
        jLabel4.setForeground(new java.awt.Color(255, 153, 0));

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel3)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 309, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                        .addComponent(jLabel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(jLabel4, javax.swing.GroupLayout.DEFAULT_SIZE, 265, Short.MAX_VALUE)))
                .addContainerGap(255, Short.MAX_VALUE))
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, 398, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, 26, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jLabel4, javax.swing.GroupLayout.PREFERRED_SIZE, 26, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(219, 219, 219)))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 53, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(61, 61, 61))
        );

        jMenuBar1.setAlignmentY(0.5F);
        jMenuBar1.setPreferredSize(new java.awt.Dimension(329, 28));

        jMenu1.setText("    File     ");

        jMenuItem1.setText("Quitter");
        jMenuItem1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem1ActionPerformed(evt);
            }
        });
        jMenu1.add(jMenuItem1);

        jMenuBar1.add(jMenu1);

        jMenu2.setText("Films        ");

        jMenuItem4.setText("Liste des Films");
        jMenuItem4.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem4ActionPerformed(evt);
            }
        });
        jMenu2.add(jMenuItem4);

        jMenuItem6.setText("Nouveau Film");
        jMenuItem6.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem6ActionPerformed(evt);
            }
        });
        jMenu2.add(jMenuItem6);

        jMenuBar1.add(jMenu2);

        jMenu4.setText("Salles          ");

        jMenuItem8.setText("Liste des salles ");
        jMenuItem8.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem8ActionPerformed(evt);
            }
        });
        jMenu4.add(jMenuItem8);

        jMenuBar1.add(jMenu4);

        jMenuItem5.setText("Liste de Séances");
        jMenu3.add(jMenuItem5);

        jMenuBar1.add(jMenu3);

        jMenu10.setText("Abonnés");

        jMenuItem7.setText("Liste des abonnés");
        jMenuItem7.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem7ActionPerformed(evt);
            }
        });
        jMenu10.add(jMenuItem7);

        jMenuBar1.add(jMenu10);

        jMenu5.setText("      Cartes     ");

        jMenuItem2.setText("Nouvelle Carte");
        jMenuItem2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem2ActionPerformed(evt);
            }
        });
        jMenu5.add(jMenuItem2);

        jMenuItem3.setText("Liste de Cartes");
        jMenuItem3.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem3ActionPerformed(evt);
            }
        });
        jMenu5.add(jMenuItem3);

        jMenuBar1.add(jMenu5);

        jMenu8.setText("?");

        jMenuItem9.setText("About Cinéma");
        jMenuItem9.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem9ActionPerformed(evt);
            }
        });
        jMenu8.add(jMenuItem9);

        jMenuBar1.add(jMenu8);

        setJMenuBar(jMenuBar1);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jPanel1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 529, Short.MAX_VALUE)
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void jMenuItem4ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem4ActionPerformed

        // TODO add your handling code here:
            /* recuperer a liste de film dans la base et les afficher dans
        le panel ListeFilms*/

        filmsList = (ArrayList<FilmsInfo>) filmDao.allFilm();
        if (filmsList.isEmpty()) {
             JOptionPane.showMessageDialog(null,
                    "aucun film dans la liste.");
        } else {
            // for (FilmsInfo fi : filmsList) {
            //  System.out.println(fi.getTitre());
            // addFilm(jPanel1, fi);}

            affichageFilm affichage;
            jPanel1.removeAll();
            try {
                affichage = new affichageFilm();
                affichage.setVisible(true);
               
                affichage.setBounds(0, 0, affichage.getPreferredSize().width,affichage.getPreferredSize().height );
                jPanel1.add(affichage);

                jPanel1.validate();
                jPanel1.repaint();
            } catch (InstantiationException ex) {
                Logger.getLogger(AdminCompte.class.getName()).log(Level.SEVERE, null, ex);
            } catch (IllegalAccessException ex) {
                Logger.getLogger(AdminCompte.class.getName()).log(Level.SEVERE, null, ex);
            }
        }




    }//GEN-LAST:event_jMenuItem4ActionPerformed

    private void formComponentAdded(java.awt.event.ContainerEvent evt) {//GEN-FIRST:event_formComponentAdded
        // TODO add your handling code here:
    }//GEN-LAST:event_formComponentAdded
    /*  consulter la liste des abonnées au cinema*/   /* Afficher la fenetre qui permet d'organiser et d'ajouter un film*/
    /* Film menu est un jFrame qui lorsque on clique sur ajouter un film
       ce jFrame est charger d'afficher le panel Nouveau Film*/
    private void jMenuItem6ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem6ActionPerformed
           NouveauFilm nfilm = new NouveauFilm();
           nfilm.setVisible(true);
             nfilm.setBounds(0, 0, nfilm.getPreferredSize().width,nfilm.getPreferredSize().height );
               FilmForm ff = new FilmForm();
               ff.setVisible(true);
                ff.add(nfilm);
    }//GEN-LAST:event_jMenuItem6ActionPerformed
 /* fermer la fenetre admin */
    private void jMenuItem1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem1ActionPerformed
        this.dispose();
    }//GEN-LAST:event_jMenuItem1ActionPerformed
  /*  afficher les différentes cartes */
    private void jMenuItem3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem3ActionPerformed
      
            CartesForm cf = new CartesForm();
            cf.setVisible(true);
            cf.setBounds(0, 0, cf.getPreferredSize().width, cf.getPreferredSize().height);
            
           
            jPanel1.removeAll();
            jPanel1.add(cf);
            jPanel1.validate();
            jPanel1.repaint();


       
    }//GEN-LAST:event_jMenuItem3ActionPerformed
/*  ajouter une nouvelle carte*/
    private void jMenuItem2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem2ActionPerformed
        /* quand je clique sur l'item Nouvelle Carte, la jFrame AjouterCarte
         doit s'ouvrir*/
        AjouterCarte ajoutCarte = new AjouterCarte();
        ajoutCarte.setVisible(true);
        ajoutCarte.setBounds(0, 0, ajoutCarte.getPreferredSize().width,ajoutCarte.getPreferredSize().height );
        ajoutCarte.setAlwaysOnTop(true);



    }//GEN-LAST:event_jMenuItem2ActionPerformed
/* afficher la liste des abonnés*/
    private void jMenuItem7ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem7ActionPerformed
        AbonneForm af = new AbonneForm();
        af.setVisible(true);
        af.setBounds(0, 0, af.getPreferredSize().width,af.getPreferredSize().height );
        jPanel1.removeAll();
            jPanel1.add(af);
            jPanel1.validate();
            jPanel1.repaint();
    }//GEN-LAST:event_jMenuItem7ActionPerformed
/* afficher la liste des salles*/
    private void jMenuItem8ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem8ActionPerformed
        SalleForm sf = new SalleForm();
        sf.setVisible(true);
        sf.setBounds(0, 0, sf.getPreferredSize().width,sf.getPreferredSize().height);
        jPanel1.removeAll();
        jPanel1.add(sf);
        jPanel1.validate();
        jPanel1.repaint();
    }//GEN-LAST:event_jMenuItem8ActionPerformed

    private void jMenuItem9ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem9ActionPerformed
        About about = new About();
        about.setVisible(true);
        about.setBounds(0, 0, about.getPreferredSize().width,about.getPreferredSize().height);
    }//GEN-LAST:event_jMenuItem9ActionPerformed
  
    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) throws IOException, SQLException, InstantiationException, IllegalAccessException {
        //ConnexionBD.loadTables(null, null);
        /* FilmsDao fd = new FilmsDao();
        FilmsInfo element = new FilmsInfo(
        0,
        "Printemps",
        new Time(1,12,3),
        "Une histoire d'amour",
        new Date(2007, 10, 21),
        "John Bash, Carrie Bradshow",
        0.3f,
        "print.jpg"
        );
        fd.saveFilm(element);
        FilmsInfo elemen = new FilmsInfo(
        1,
        "Salt",
        new Time(1,40,3),
        "Une histoire d'amour",
        new Date(2010, 10, 21),
        "John Bash, Carrie Bradshow",
        0.3f,
        "img.jpg"
        );
        fd.saveFilm(elemen);*/
        java.awt.EventQueue.invokeLater(new Runnable() {

            public void run() {
                try {
                    new AdminCompte().setVisible(true);
                } catch (InstantiationException ex) {
                    Logger.getLogger(AdminCompte.class.getName()).log(Level.SEVERE, null, ex);
                } catch (IllegalAccessException ex) {
                    Logger.getLogger(AdminCompte.class.getName()).log(Level.SEVERE, null, ex);
                }
            }
        });
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JMenu jMenu1;
    private javax.swing.JMenu jMenu10;
    private javax.swing.JMenu jMenu11;
    private javax.swing.JMenu jMenu2;
    private javax.swing.JMenu jMenu3;
    private javax.swing.JMenu jMenu4;
    private javax.swing.JMenu jMenu5;
    private javax.swing.JMenu jMenu6;
    private javax.swing.JMenu jMenu7;
    private javax.swing.JMenu jMenu8;
    private javax.swing.JMenu jMenu9;
    private javax.swing.JMenuBar jMenuBar1;
    private javax.swing.JMenuBar jMenuBar2;
    private javax.swing.JMenuBar jMenuBar3;
    private javax.swing.JMenuItem jMenuItem1;
    private javax.swing.JMenuItem jMenuItem2;
    private javax.swing.JMenuItem jMenuItem3;
    private javax.swing.JMenuItem jMenuItem4;
    private javax.swing.JMenuItem jMenuItem5;
    private javax.swing.JMenuItem jMenuItem6;
    private javax.swing.JMenuItem jMenuItem7;
    private javax.swing.JMenuItem jMenuItem8;
    private javax.swing.JMenuItem jMenuItem9;
    private javax.swing.JPanel jPanel1;
    // End of variables declaration//GEN-END:variables
    /*
    private void addFilm(JPanel jPanel1, FilmsInfo fi){


    try {

    affichageFilm lfilm = new affichageFilm(fi);
    lfilm.setBounds(0, 0, 800, 800);
    jPanel1.add(lfilm);


    /* affichageFilm lfilm = new affichageFilm(fi);
    int decalage = 5;
    int pwidth = 300;
    int pheight = 600;
    int mxwidth = 600;

    System.out.println(filmsList.size());
    int x = (((filmsList.size() % (mxwidth / pwidth)) + 1) * decalage) + ((filmsList.size() * pwidth) % mxwidth);
    int y = (((filmsList.size() / (mxwidth / pwidth)) + 1) * decalage) + (filmsList.size() / (mxwidth / pwidth) * pheight);
    lfilm.setVisible(true);
    // lfilm.setBounds(x, y, pheight, mxwidth);
    lfilm.setBounds(x, y, 600, 600);

    jPanel1.add(lfilm);
    jPanel1.setPreferredSize(new Dimension(jPanel1.getPreferredSize().width, y+pheight));*/
    // this.add(jPanel1);
    /*    } catch (InstantiationException ex) {
    Logger.getLogger(AdminCompte.class.getName()).log(Level.SEVERE, null, ex);
    } catch (IllegalAccessException ex) {
    Logger.getLogger(AdminCompte.class.getName()).log(Level.SEVERE, null, ex);
    }

    }

     */
}
